package com.ihr360.payroll.controller.salaryprofile;


import com.ihr360.maven.plugin.ModuleCodeStore;
import com.ihr360.maven.plugin.annotation.FunctionDefinition;
import com.ihr360.maven.plugin.annotation.ModuleDefinition;
import com.ihr360.payroll.model.dto.staff.SalaryProfileField;
import com.ihr360.payroll.service.salaryprofile.SalaryProfileFieldService;
import com.ihr360.rest.service.SimpleRestService;
import com.ihr360.rest.webmvc.AbstractRestSimpleWithLongIdController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/salaryProfileFields")
@ModuleDefinition(mainModuleCode = ModuleCodeStore.Module.SALARY_CODE, mainModuleName = ModuleCodeStore.Module.SALARY_NAME, hasExtendsAbstractRestController = true,
        subModuleCode = ModuleCodeStore.Module.Salary.STAFF_PAY_ROLLINFO_CODE, subModuleName = ModuleCodeStore.Module.Salary.STAFF_PAY_ROLLINFO_NAME)
public class SalaryProfileFieldController extends AbstractRestSimpleWithLongIdController<SalaryProfileField> {

    @Autowired
    private SalaryProfileFieldService salaryProfileFieldService;

    @Override
    public SimpleRestService<SalaryProfileField, Long> getSimpleRestService() {
        return salaryProfileFieldService;
    }


    @FunctionDefinition(functionName = "删除公司薪资元字段", functionCode = ModuleCodeStore.Function.EDIT, isPublic = true)
    @DeleteMapping(value = "/company/{id}")
    public void deleteOne(@PathVariable(value = "id") Long id) {
        salaryProfileFieldService.deleteOne(id);
    }

    @FunctionDefinition(functionName = "批量删除公司薪资元字段", functionCode = ModuleCodeStore.Function.EDIT, isPublic = true)
    @DeleteMapping(value = "/company/batch")
    public void deleteOne(@RequestBody List<Long> ids) {
        salaryProfileFieldService.batchDelete(ids);
    }


}
